package server

import (
	"sanguo/node/common/db"
	"sanguo/node/node_dir"
	"strconv"
)

func updateLastLogin(userId string, serverId int) {
	node_dir.Infoln(userId, "updateLastLogin", serverId)
	key := "last_login_map"
	field := userId
	ok, err := db.GetRedisClient("dir").HSet(key, field, serverId).Result()
	if nil != err {
		node_dir.Infoln(userId, "updateLastLogin fail", err, ok)
	}
}

func logged(userId string, serverId int, pLevel int) {
	node_dir.Infoln(userId, "logged", serverId, pLevel)
	key := "logged:" + userId
	field := strconv.FormatInt(int64(serverId), 10)
	ok, err := db.GetRedisClient("dir").HSet(key, field, pLevel).Result()
	if nil != err {
		node_dir.Infoln(userId, "logged fail", err, ok)
	}
}
